<?php 
function send_mail($subject,$email_to,$messenger,$not_bcc=0){
	$ci = &get_instance();
	$ci->load->library('email');
	$config['mailtype'] = 'html';
	$ci->email->initialize($config);
	$ci->email->from($ci->config->item('email'), $ci->config->item('company_name'));
	$ci->email->to($email_to);
	if($not_bcc == 1)
		$ci->email->bcc($ci->config->item('email'));
	$ci->email->subject($subject);
	$ci->email->message($messenger);
	$ci->email->send();
}
function send_mail_multi($subject,$info_customer,$messenger,$footer="",$active_unsubcribe=0){
	$count_email = 0;
	if(count($info_customer)>0){
		$list_email_send = array();
		foreach($info_customer as $item){
			if(!in_array($item["email"],$list_email_send)){
				if($active_unsubcribe == 1)
					$messenger .= "<p> Nếu không muốn nhân tin từ Plusmainichi thì bạn click vào đây để <a href='".site_url("secure/cancel_email?t=".$item["type"]."&co=".$item["code_active"])."'> hủy nhận thông báo </a>.</p>".$footer;
				$list_email_send[] = $item["email"];
				if(empty($item["fullname"])){
					$array_name = explode("@",$item["email"]);
					$name = $array_name[0];
				}else
					$name = $item["fullname"];
				send_mail($subject,$item["email"],$messenger);
				$count_email ++;
			}			
		}	
	}
	return $count_email;
}